//
//  UIBarButtonItem + Extesion.swift
//  weibo
//
//  Created by 上官风雨 on 15/11/19.
//  Copyright © 2015年 上官风雨. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    convenience init(imageName: String,target: AnyObject?,actionName: String?){
        let btn = UIButton()
        if  let targetObj = target, action = actionName {
            
            btn.addTarget(targetObj, action:Selector(action), forControlEvents: .TouchUpInside)
        }
        btn.setImage(UIImage(named: imageName), forState: .Normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        btn.sizeToFit()
       
        self.init(customView:btn)
    }

}
